package de.duester.genealogy;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import de.duester.genealogy.model.dao.DaoMaster;
import de.duester.genealogy.model.dao.DaoMaster.OpenHelper;
import de.duester.genealogy.model.dao.DaoSession;

public class Utility {
	public static Context context;

	private static String dbName;
	private static OpenHelper helper;
	private static SQLiteDatabase db;
	private static DaoMaster daoMaster;
	private static DaoSession daoSession;

	public static void openDB(String dbName) {
		Utility.dbName = dbName;
		helper = new DaoMaster.DevOpenHelper(context, dbName + ".db", null);
		db = helper.getWritableDatabase();
		daoMaster = new DaoMaster(db);
		daoSession = daoMaster.newSession();
	}

	public static String getDBName() {
		return dbName;
	}

	public static SQLiteDatabase getDB() {
		return db;
	}

	public static void refreshSession() {
		daoSession = daoMaster.newSession();
	}

	public static DaoSession getDaoSession() {
		return daoSession;
	}
}
